<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:if test="${captainQuery.message != null}">
	<script type=text/javascript>
	  <!--
		  alert("${captainQuery.message}");
		  window.location = "${captainQuery.location}"
	  //-->
	</script>
</c:if>

<c:if test="${captainMap.module=='list'}">
<h2>Captain Team of "${captainMap.teamNameCaptain}"</h2>
<hr/>

<a href="<c:url value='/captainAdd.htm?teamId=${captainMap.teamIdCaptain}'/>">Add Captain</a>
<table border="1" width="350px">
	<tr>
		<th width="10%" bgcolor="#0000CC"><font color="#FFFFFF"><b>No</b></font></th>
		<th width="60%" bgcolor="#0000CC"><font color="#FFFFFF"><b>Captain Name</b></font></th>
		<th width="30%" bgcolor="#0000CC"><font color="#FFFFFF"><b>Action</b></font></th>		
	</tr>
	<c:forEach items="${captainMap.listCaptain}" var="captain" varStatus="captainCount">
	<tr>
	    <c:if test="${captainCount.count % 2 == 0}">
	    	<td align="center" bgcolor="#C1E0FF">${captainCount.count}</td>
			<td align="left" bgcolor="#C1E0FF">${captain.firstName} ${captain.lastName}</td>
			<td align="center" bgcolor="#C1E0FF">
			    <a href="captainDelete.htm?teamId=${captainMap.teamIdCaptain}&playerId=${captain.playerId}" onClick="return confirm('Are you sure to delete this data?')">Delete</a> 			    
			</td>
	    </c:if>
	    <c:if test="${captainCount.count % 2 == 1}">
	    	<td align="center" bgcolor="#E1F0FF">${captainCount.count}</td>
			<td align="left" bgcolor="#E1F0FF">${captain.firstName} ${captain.lastName}</td>
			<td align="center" bgcolor="#E1F0FF">
			    <a href="captainDelete.htm?teamId=${captainMap.teamIdCaptain}&playerId=${captain.playerId}" onClick="return confirm('Are you sure to delete this data?')">Delete</a> 			    
			</td>
	    </c:if>
	</tr>
	</c:forEach>
</table>
</c:if>
 
<c:if test="${captainMap.module=='add'}">
<h2>Add Captain</h2>
<hr/>
 
<form action="captain.htm" method="post">
	<input type="hidden" name="teamId" value="${captainMap.teamId}"/>	
	<table>	
		<tr>
			<td>Captain Name</td>
			<td>:</td>
			<td>
				<select name="playerId">
					<option value="">- Choice Player -</option>
					<c:forEach items="${captainMap.playerList}" var="player">
						<option value="${player.playerId}">${player.firstName} ${player.lastName}</option>
					</c:forEach>
				</select>
			</td>
		</tr>		
		<tr>
			<td></td>
			<td></td>
			<td>
				<input type="submit" name="save" value="Save" onClick="return confirm('Are you sure to save this data?')"/>
				<input type="button" name="cancel" value="Cancel" onClick="javascript:history.back(1)"/>
			</td>
		</tr>
	</table>	 
</form>
</c:if>